<?php
/**
 * 首页微博分享推荐
 * 
 * @copyright dongping
 * @since 2012-04-09
 */

error_reporting(0);

/* 引入相关文件 */
include_once($_SERVER["DOCUMENT_ROOT"]. "/core/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"]. "/config/inc.php");
include_once($_SERVER["DOCUMENT_ROOT"] . "/core/admin.inc.php");
include_once($_SERVER["DOCUMENT_ROOT"]. "/include/foodv2/inc.php");

// 所有的参数
$g_cgival = array();
// 存储中间数据 非输出数据 可以不用
$g_pro    = array();
// 要显示的数据 输出数据
$g_show   = array();


function check_cgi_pro()
{
	global $g_cgival, $g_pro, $g_show;
	
	
	cgi::both($g_cgival["id"], "id", 0);
	$g_cgival["id"] = intval($g_cgival["id"]);
}

function get_data()
{
	global $g_cgival, $g_pro, $g_show;
	
	$g_show = $g_cgival;
	$id = $g_cgival["id"];

	
	

	// 拿到当前站点的site_id
	$site_id = admin::admin_get_user_site_id();
	$admin_id = admin::admin_get_login_uid();
	$admin_name = admin::admin_get_login_user_name();	

	
	$admin_log = new admin_log();
	$db = new db_food_index_share_tj();

	$ret = $db->delete_share_item(admin_id, $admin_name, $site_id, $id);
	if ($ret == false)
	{
		throw new Exception("删除失败！");
	}
	
	$admin_log->admin_insert_log_info($admin_id, $site_id, 6, "删除 首页美食分享id={$id}");
}

try
{
	admin_check_login();
// 	admin_check_user_priv("foodv2/main_nav.php");
	
	check_cgi_pro();
	get_data();
	
	$g_show["error"] = 0;
	$g_show["errmsg"] = "";	
}
catch(Exception $e)
{
	$g_show["error"] = 1;
	$g_show["errmsg"] = $e->getMessage();
}

show_pro();
exit;


function show_pro()
{
	global $g_show;

	echo json_encode($g_show);
}

?>